/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tutorial.DesignPatterns.Singleton;

/**
 * Asta ii destul de simplu 
 * in netbeans daca dai new sa faci o clasa noua la other poti sa alegi singleton :P
 * Se creaza obiectul normal dar se face construtorul private (sau protected)
 * si cu o metoda statica se returnea o singura instanta a lui cum se vede mai jos
 * @author Boogie
 */
public class Singleton {
    private static Singleton instance;
    
    private int test;
    private Singleton(){
        test = 0;
    }
    
    public static Singleton getInstance(){
        if(instance == null){
            instance = new Singleton();
        }
        return instance;
    }
    
    public void someMethod(){
        System.out.println("Some Method!");
    }
    /**
     * metoda de test care arata ca se instanteza doar odata
     */
    public void someOtherMethod(){
        System.out.println("Test:"+test);
        test++;
    }
}
